/**
 * JAVA5中线程池概念
 */
package com.vinfai.thread.concurrent;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author vinfai
 *
 */
public class ThreadPool {

	public ThreadPool() {
	}

	public static void main(String[] args) {
		//ExecutorService pool = Executors.newFixedThreadPool(4);
		ScheduledExecutorService pool  = Executors.newScheduledThreadPool(4);
		Thread t1 = new MyThread2("线程1");
		Thread t2 = new MyThread2("线程2");
		Thread t3 = new MyThread2("线程3");
		Thread t4 = new MyThread2("线程4");
		Thread t5 = new MyThread2("线程5");
		//CopyOnWriteArrayList 
		
//		pool.execute(t1);
//		pool.schedule(t2, 5, TimeUnit.SECONDS);
//		pool.execute(t3);
//		pool.execute(t3);
		pool.scheduleAtFixedRate(t5, 5, 2, TimeUnit.SECONDS);
//		pool.execute(t5);
		pool.shutdown();
		
		long t = TimeUnit.MINUTES.toHours(58);
		System.out.println(t);
		
		
	}

}
class MyThread2 extends Thread{
	private String name ;
	public MyThread2(){}
	public MyThread2(String name){
		super(name);
		this.name = name;
	}
	@Override
	public void run(){
		//for(int i=1;i<11;i++)
			//System.out.println(Thread.currentThread().getName()+" is running....");
			System.out.println(name+(Thread.currentThread().getName())+" is running....bombing.... ");
			//System.out.println("bombing....");
	}
}
